package com.chen.demo.rhombus.ohs.local.pl.executor;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chen.demo.rhombus.acl.port.repository.UserRepository;
import com.chen.demo.rhombus.domain.vo.UserVo;
import com.chen.demo.rhombus.ohs.local.pl.command.query.UserPageQuery;
import com.chen.winnerframework.cqrs.executor.CommandExecutor;
import com.chen.winnerframework.http.response.PageResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class UserPageQryExe implements CommandExecutor<UserPageQuery, PageResponse<UserVo>> {

    private final UserRepository userRepository;

    @Override
    public PageResponse<UserVo> execute(UserPageQuery pageQuery) {
        Page<UserVo> userVoPage = userRepository.selectUserByPage(pageQuery);
        return PageResponse.success(userVoPage);
    }
}
